package com.ycy.plugin;

public abstract class SymmetricAlgorithm {

  protected String dataSecret;

  protected String dataSecretiv;

  /**
   * 必要
   * "算法/模式/补码方式"
   * eg："AES/CBC/PKCS5Padding"
   */
  protected String secretType;

  /**
   * 非必要，默认采用hex
   */
  protected String out;

  /**
   * 非必要，默认采用算法自身实现
   */
  protected String toCase;



  public abstract String encrypt(String src) throws Exception;

  public abstract String decrypt(String src) throws Exception;

  public String crypt(String CRYPT_MODE, String src) throws Exception {
    if ("decrypt".equalsIgnoreCase(CRYPT_MODE)) {
      return decrypt(src);
    } else if ("encrypt".equalsIgnoreCase(CRYPT_MODE)) {
      return encrypt(src);
    }
    return null;
  }

}
